<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>文件列表</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<style type="text/css">
		
	</style>
</head>
<body>
	<%@ include file="include/topbar.jsp" %>
		<div class="container" style="margin-top: 60px">
			<div class="row">
				<jsp:include page="include/left.jsp">
					<jsp:param value="share" name="tag"/>
				
				</jsp:include>
				
								<div class="modal fade" id="delalert">
								    <div class="modal-header">
								    	<a class="close" data-dismiss="modal">×</a>
								    <h3>系统提示</h3>
								    </div>
								    <div class="modal-body">
								   		<p style="text-align:center">确定要删除么？</p>
								    </div>
								    <div class="modal-footer">
								    <a href="#" class="btn" data-dismiss="modal">返回</a>
								    <a href="javascript:;" title="删除" class="btn btn-primary"id="btn-del" data-dismiss="modal">确认删除</a>
								    </div>
								</div>
				
		
		<div class="span9 ">
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius:3px 3px 0 0">	
						
							<h4 style="display:inline"><i class=" icon-file"></i><a href="file.jspx">${foldername }</a><span class="divider">/</span>文件列表</h4>

							<a href="upload.jspx" class=" pull-right"><i class="icon-plus "></i>上传文件</a>
						
			</ul>	
			
		<div class=" wall" style="padding:15px">
          	<table class="table table-striped">
          	<c:if test="${empty filelist }">
          				<p style="text-align:center">暂时没有文件！</p>
          	</c:if>
          	<c:if test="${ not empty filelist }">
          		<thead>
          			<tr>
          				<th style="width:7%"></th>
          				<th style="width:70%">文件名称</th>
          				<th style="width:10%">大小</th>
          				<th>上传人</th>
          			</tr>
          		
          		</thead>
          	
          		<tbody>
          			
          			<c:forEach items="${filelist }" var="f">
          				<tr id="${f.id }">
          				<c:choose>
          					<c:when test="${f.type eq '.pdf' }"><td style="width:7%;"><img src="img/pdf.png"  width="24px"/></td></c:when>
          					<c:when test="${(f.type eq '.rar') or(f.type eq '.zip') }"><td style="width:7%;"><img src="img/rar.png"  width="24px"/></td></c:when>
          					<c:when test="${f.type eq '.doc' }"><td style="width:7%;"><img src="img/doc.png"  width="24px"/></td></c:when>
          					<c:when test="${f.type eq '.xls' }"><td style="width:7%;"><img src="img/xls.png"  width="24px"/></td></c:when>
          					<c:when test="${f.type eq '.ppt' }"><td style="width:7%;"><img src="img/ppt.png"  width="24px"/></td></c:when>
          					<c:when test="${f.type eq ('.png' or '.gif' or '.jpg' or '.jepg' or '.bmp') }"><td style="width:7%;"><img src="img/pic.png"  width="24px"/></td></c:when>
          					
          				</c:choose>
          					
          					<td style="width:70%"><a href="download.jspx?filename=${f.fileName }">${f.name }</a></td>
          					<td>
          						<c:if test="${f.fileSize/1024/1024 >1 }"><fmt:formatNumber value="${f.fileSize/1024/1024 }" type="number" pattern="#.##" />Mb</c:if>
          						<c:if test="${f.fileSize/1024/1024 <1 }"><fmt:formatNumber value="${f.fileSize/1024 }" type="number" pattern="#.##" />Kb</c:if>
          					</td>
          					
          					<td >${f.empName }<c:if test="${f.employeeId eq employee.id }"><a rel="${f.id }" href="#delalert" data-toggle="modal"><i class="icon-trash pull-right" title="删除"></i></a></c:if></td>
          				</tr>
          			
          			</c:forEach>
          			
          		
          		</tbody>
          	</c:if>
          	</table>
        
      </div>

	</div>
</div></div>
	
	<script type="text/javascript">
		$(document).ready(function(){
			var fileid;
			$("a[rel]").click(function(){
				 fileid = $(this).attr("rel");
			});
			
			$("#btn-del").click(function(){
			
				$.ajax({
					url:"delfile.jspx",
					type:"POST",
					data:{
						fileid:fileid
						
					},
					success:function(){
						$("#"+fileid).remove();
					}
				});
			});
			
			
		
		});
	
	</script>
</body>
</html>
